﻿using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;

using Bling.Core;
using Bling.WPF;
using Bling.WPF.Util;
using Bling.Slides;
using Bling.Util;
using Bling.Shaders;
using Bling.Graphics;

namespace Bling.NewGen.Test {
  using Bling.NewGen;
  using System.Collections.Generic;
  using System.Reflection;
  public class MyGenerator : Generator<Dictionary<string, object>, object> {
    public static readonly MyGenerator Instance = new MyGenerator();
    private MyGenerator() : base("MyGen") { }
    protected override Type Base<S, T>() {
      return typeof(UseBaseClass<S, T>);
    }
    protected override IList<Type> Interfaces<S, T>() {
      return new Type[] { typeof(T) };
    }
    public override Func<S, K> GetProperty<S, T, K>(PropertyInfo Property) {
      return s => {
        return (K) s[Property.Name];
      };
    }
    public override Action<S, K> SetProperty<S, T, K>(PropertyInfo Property) {
      return (s, v) => {
        s[Property.Name] = v;
      };
    }
    protected override object CallMethod<S, T>(MethodInfo Method) {
      return new Func<S, string, int, int>((s, x,y) => {
        Console.WriteLine("Foo(" + x + ", " + y + ")");
        return 42;
      });
    }
  }


  public class MyTest {
    public interface ITest {
      int m { get; set; }
      int n { get; set; }
      int foo(string  x, int y);
    }
    public static void DoTest() {
      var dict = new Dictionary<string, object>();
      var obj = MyGenerator.Instance.Create<Dictionary<string, object>, ITest>(dict);
      obj.m = 10;
      obj.n = 20;
     
      int value = obj.m;
      var hello = obj.foo("0", 1);
      Console.WriteLine("Answer: " + value);
    }

  }

}

namespace Bling.Physics.Example {



  public class Driver : SlideHolder {
    public Driver() {
      Bling.NewGen.Test.MyTest.DoTest();
      this["Earth"] = () => new Bling.Example.Earth();

      this["Bezier"] = () => new Bling.TestP.BezierTest();
      this["Volume"] = () => new Bling.Example.FakeVolume();
      this["Chain"] = () => new Bling.Tutorial.PhysicsChain();
      this["Fan"] = () => new FanA();
    }
    [STAThread]
    public static void Main(string[] args) {
      var win = new Window() { Title = "Bling Physics Example", Content = new Driver() };
      new Application().Run(win);
      return;
    }
  }
}
